<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>员工列表练习</title>
    <style>
        body{
            background-color: #e8e8e8;
            font:32px cursive;
        }
        table{
            border: 1px solid black;
            border-radius: 3px;
        }
        td,th{
            border: 1px solid blue;
            border-radius: 3px;
        }
        input[type="text"],input[type="password"]{
            width: 200px;
            height: 35px;
            border-radius: 5px;
            font-size: 25px;
            background-color: #e8e8e8;
        }
        input[type="button"]{
            width: 80px;
            height: 35px;
            text-align: center;
            font-size: 20px;
            border-radius: 3px;
        }
    </style>
</head>
<body>
<div>
    <input type="text" placeholder="姓名"v-model="name">
    <input type="text" placeholder="工资" v-model="salary">
    <input type="text" placeholder="工作" v-model="job">
    <input type="button" value="添加" @click="add()">
    <table border="1">
        <caption>员工列表</caption>
        <tr>
            <th>编号</th>
            <th>姓名</th>
            <th>工资</th>
            <th>职位</th>
            <th>操作</th>
        </tr>
        <tr v-for="(people,i) in array">
            <td>{{i+1}}</td>
            <td>{{people.name}}</td>
            <td>{{people.salary}}</td>
            <td>{{people.job}}</td>
            <!--删除arr数组中i下标位置的对象-->
            <td><input type="button" value="删除" @click="array.splice(i,1)"></td>
        </tr>
    </table>
</div>
<script src="../js/vue.js"></script>
<script>
    let v=new Vue({
        el:"div",
        data:{
           name:"",
           salary:"",
           job:"",
           array:[],
        },
        methods:{
            add(){
                //往arr数组中添加一个对象
                v.array.push({name:v.name,salary:v.salary,job:v.job});
                v.name="";v.salary="";v.job="";
            }
        }
    })
</script>
</body>
</html>